
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import twitter4j.Query;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Mauricio
 */
public class JTextListener implements ActionListener{    
    private NewJPanel Panel;
    public JTextListener(NewJPanel p){
        Panel=p;
    };

    public void actionPerformed(ActionEvent e) {
        JLabel label = new JLabel();
        label = Panel.getLabel();
        if (label.getText()=="Introduzca Usuario"){
            System.out.println("Buscaste a " +Panel.getTextField().getText()+ "y ademas " + Panel.lepan.getComponentCount());
            Panel.lepan.remove(Panel.lepan.pan);
            Panel.lepan.pan =  new TimelinePane(Panel.twt,false,"tweets",Panel.getTextField().getText());
            Panel.lepan.add(Panel.lepan.pan, Panel.lepan.gbc);
            Panel.lepan.repaint();
            Panel.lepan.ventana.relayer();
            Panel.lepan.ventana.repaint();
            
        }
        else if (label.getText()=="Introduzca palabra clave"){
            System.out.println("Buscaste la palabra " +Panel.getTextField().getText());
            Panel.lepan.remove(Panel.lepan.pan);
            Query buscar = new Query(Panel.getTextField().getText());
            buscar.setRpp(50);
            Panel.lepan.pan =  new TimelinePane(Panel.twt,false,"search",buscar);
            Panel.lepan.add(Panel.lepan.pan, Panel.lepan.gbc);
            Panel.lepan.repaint();
            Panel.lepan.ventana.relayer();
            Panel.lepan.ventana.repaint();
        }
    }
    
    
}
